﻿<mui:ModernWindow x:Class="ModernAudioTagger.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mui="http://firstfloorsoftware.com/ModernUI"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
        xmlns:settings="clr-namespace:ModernAudioTagger.Settings"
        xmlns:provider="clr-namespace:ModernAudioTagger.Provider"
        xmlns:view="clr-namespace:ModernAudioTagger.View"
        xmlns:helpers="clr-namespace:ModernAudioTagger.Helpers"
        BackgroundContent="{StaticResource WindowBackgroundContent}"
        Title="{StaticResource app_title}" 
        IsTitleVisible="True"
        WindowStartupLocation="CenterScreen"
        AllowDrop="True"
        LogoData="{StaticResource tagPathData}"     
        Icon="Assets/little_icon.ico"
        ContentSource="/Pages/ExplorerPage.xaml">


    <helpers:DragDropBehaviour.DragEnterCommand>
        <Binding Source="{x:Static provider:ViewModelLocator.Instance}" Path="LocalSystemVM.DragEnterCommand" />        
    </helpers:DragDropBehaviour.DragEnterCommand>

    <helpers:DragDropBehaviour.DropCommand>
        <Binding Source="{x:Static provider:ViewModelLocator.Instance}" Path="LocalSystemVM.DropFilesCommand" />
    </helpers:DragDropBehaviour.DropCommand>

    <mui:ModernWindow.MenuLinkGroups>
        <!--<mui:LinkGroup DisplayName="welcome">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="home" Source="/Pages/Home.xaml" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>-->
        <mui:LinkGroup DisplayName="actions">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="explorer" Source="/Pages/ExplorerPage.xaml" />
                <mui:Link DisplayName="manual tag" Source="/Pages/AudioTag.xaml" />
                <mui:Link DisplayName="database search" Source="/Pages/MusicDbSearch.xaml" />
                <mui:Link DisplayName="automatic tag" Source="/Pages/TagDbResult.xaml" />                
                <mui:Link DisplayName="rename" Source="/Pages/Rename.xaml" />
            </mui:LinkGroup.Links>               
        </mui:LinkGroup>
        <!--
        <mui:LinkGroup DisplayName="rename">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="rename" Source="/Pages/Rename.xaml" />                
            </mui:LinkGroup.Links>
        </mui:LinkGroup>
        -->
        <mui:LinkGroup DisplayName="tools">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="batch helper" Source="/Pages/Batch.xaml" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>
        <mui:LinkGroup DisplayName="settings" GroupName="settings">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="software" Source="/Pages/Settings.xaml" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>
    </mui:ModernWindow.MenuLinkGroups>

    <mui:ModernWindow.TitleLinks>
        <mui:Link DisplayName="settings" Source="/Pages/Settings.xaml" />
    </mui:ModernWindow.TitleLinks>
    
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closing">
            <i:InvokeCommandAction Command="{Binding Source={x:Static settings:SettingsManager.Instance}, Path=SaveMainCommand}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="SoftwareOutOfDateEvent" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=NetworkVM}">
            <!--<i:Interaction.Behaviors>
                <helpers:EventTriggerBehavior Attacher="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window} }}" />
            </i:Interaction.Behaviors>-->
            <view:InvokeDelegateCommandAction 
                Command="{x:Static view:ViewCommands.ShowMessageOutOfDateVersionCommand}" 
                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" 
                />
        </i:EventTrigger>
        <i:EventTrigger EventName="Loaded">
            <i:InvokeCommandAction Command="{Binding Source={x:Static settings:SettingsManager.Instance},  Path=LoadNetworkCommand}" />
            <i:InvokeCommandAction Command="{Binding Source={x:Static settings:SettingsManager.Instance},  Path=LoadMainCommand}" />
            <i:InvokeCommandAction Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=NetworkVM.ProxyChangedCommand}" />
            <i:InvokeCommandAction Command="{x:Static view:ViewCommands.InitContainerCommand}" />
            <i:InvokeCommandAction Command="{x:Static view:ViewCommands.InitResourcesCommand}" />
            <i:InvokeCommandAction Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=NetworkVM.CheckAppUpdatesCommand}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="OnFilelistUpdatedEvent" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=LocalSystemVM}">
            <i:InvokeCommandAction Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=MusicDbVM.ClearAllSelectedCommand}" />
        </i:EventTrigger>
        <!--<i:EventTrigger EventName="OnExecutingTagging" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=LocalSystemVM}">
            <i:InvokeCommandAction Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=MainVM.StopFileCommand}" />
        </i:EventTrigger>-->
        <i:EventTrigger EventName="OnFilesRenamedEvent" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=RenameVM}">
            <i:InvokeCommandAction Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=LocalSystemVM.RefreshFilelistCommand}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="OnDbSearchUpdatedEvent" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=MusicDbVM}">
            <i:InvokeCommandAction Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=LocalSystemVM.RefreshFilelistCommand}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="OnFolderRenamedEvent" SourceObject="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=RenameVM}">
            <!--<i:Interaction.Behaviors>
                <helpers:EventTriggerBehavior Attacher="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window} }}" />
            </i:Interaction.Behaviors>-->
            <view:InvokeDelegateCommandAction 
                Command="{Binding Source={x:Static provider:ViewModelLocator.Instance}, Path=LocalSystemVM.RefreshSelectedPathCommand}" 
                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" 
                />
        </i:EventTrigger>
        
    </i:Interaction.Triggers>

</mui:ModernWindow>
